﻿using System;



namespace Stock.Core
{
	public class RedisService:IRedisService
	{
		private IRedisProvider _redis;
		public RedisService(IRedisProvider redis)
		{
			_redis = redis;
		}

		public dynamic GetValue<T>(string key)
		{
			var redis = _redis.GetDatabase();

			var user = redis.JsonGet<T>(key);

			if (user == null)
			{
				return null;
			}

			return user;
		}

		public void SetValue<T>(string key, T value)
		{
			var redis = _redis.GetDatabase();

			//var l = new LogSettings() { Debug = true, Error = true, Path = "" };

            redis.JsonSet<T>(key, value, null);

		}
	}
}
